package com.catering.controller;

import com.catering.pojo.DOrderinformation;
import com.catering.service.DOrderinformationService;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("order")
public class DOrderinformationController {
    @Resource
    private DOrderinformationService dOrderinformationService;
    //查询所有的订单信息
    @RequestMapping("list")
    public List<DOrderinformation> list(){
        return dOrderinformationService.list();
    }

    //取餐 根据status=2
    @RequestMapping("take")
    public List<DOrderinformation> take(){
        return dOrderinformationService.take();
    }

    /**
     * 批量添加订单项
     * 
     * @param orderItems 订单项集合
     * @return 结果
     */
    @PostMapping("/addBatchOrderItems")
    public Map<String, Object> addBatchOrderItems(@RequestBody List<DOrderinformation> orderItems) {
        return dOrderinformationService.addBatchOrderItems(orderItems);
    }
}
